package net.tngou.c4j.ml;

import java.util.List;

import org.apache.commons.collections.map.HashedMap;

import net.tngou.crawler.pojo.Ml;

/**
 * 预测
 * @author tngou@tngou.net
 *
 */
public class Forecast {

	
	public static  boolean Result(List<Model> list) {
		for (Model e : list) {
			if(!Result(e)) return false;
		}	
		return true;	
	}
	

	public static boolean Result(Model model) {
		@SuppressWarnings("unchecked")
		Ml ml = (Ml) new Ml().get(new HashedMap() {{
			put("keyword", model.getKey());
		}});
		return Result(model,ml);
	}
	
	public static boolean Result(Model model,Ml ml) {
		if(ml==null||model==null) return false;
		if(ml.getType()!=model.getType()||ml.getIsnull()!=model.getIsnull()) 
			return false;	
		if(model.getLength()<ml.getMinlength()||model.getLength()>ml.getMaxlength())
			return false;		
		if(model.getWord()<ml.getMinword())
			return false;	
		if(model.getFilterword()>ml.getFilterword())
			return false;
		return true;
		
	}
}
